package top.someapp.dxf2dsvg.jfx;

import java.text.MessageFormat;
import java.util.ResourceBundle;

/**
 * @author zwz
 * Created on 2020-04-23
 */
public class I18N {
    private static ResourceBundle bundle;
    private static final ResourceBundle.Control control = new ResourceBundleControl();

    private I18N() {
        // prevent outer new instance
    }

    public static String getString(String key) {
        return getBundle().getString(key);
    }

    public static String getAndFormat(String key, Object... arguments) {
        final String pattern = getString(key);
        return MessageFormat.format(pattern, arguments);
    }

    public static synchronized ResourceBundle getBundle() {
        if (bundle == null) {
            bundle = ResourceBundle.getBundle("jfx.i18n", control);
        }
        return bundle;
    }
}
